"use strict";

//enum TriangleType { Error, Scalene, Isosceles, Equilateral };
var TriangleType = { 
"Error": 0, 
"Scalene": 1, 
"Isosceles": 2, 
"Equilateral": 3
};

Object.freeze(TriangleType);

function GetTriangleType(side1: number, side2: number, side3: number) {
    if (side1 <= 0 || side2 <= 0 || side3 <= 0) {
        return TriangleType.Error;
    }
    
    var s1 = side1;
    var s2 = side2;
    var s3 = side3;

    if ((s1 + s2 <= s3) || (s1 + s3 <= s2) || (s2 + s3 <= s1)) {
        return TriangleType.Error;
    }

    var e1 = s1 === s2;
    var e2 = s1 === s3;

    if (e1 && e2) {
        return TriangleType.Equilateral;
    }

    var e3 = s2 === s3;

    if (e1 || e2 || e3) {
        return TriangleType.Isosceles;
    }

    return TriangleType.Scalene;
}

